<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    html *{
      padding: 0;
      margin: 0;
    }
    .left-middle-right {
      margin-bottom: 20px;
    }
    .left-middle-right > div {
      height: 100px;
    }
  </style>
</head>
<body>
  题目：假设高度已知，请写出三栏布局，其中左、右栏宽度各为 300 px，中间自适应。

  <div>
    扩展：
    <li>五种方案各自优缺点</li>
    <li>高度未知仍然可以用的是 flex 布局和表格布局</li>
  </div>

  <!-- float 布局 -->
  <section>
    <style>
      .left-float {
        float: left;
        width: 300px;
        background: green;
      }
      .middle-float {
        background: red;
      }
      .right-float {
        float: right;
        width: 300px;
        background: yellow;
      }
    </style>
    <article class="left-middle-right">
      <div class="left-float"></div>
      <div class="right-float"></div>
      <div class="middle-float">
        1.float 布局
        2.float 布局
      </div>
    </article>
  </section>
  <!-- position 布局 -->
  <section>
    <style>
      .left-position {
        position: absolute;
        left: 0;
        width: 300px;
        background: green;
      }
      .middle-position {
        position: absolute;
        left: 300px;
        right: 300px;
        background: red;
      }
      .right-position {
        position: absolute;
        right: 0;
        width: 300px;
        background: yellow;
      }
    </style>
    <article class="left-middle-right">
      <div class="left-position"></div>
      <div class="middle-position">
        1.position 布局
      </div>
      <div class="right-position"></div>
    </article>
  </section>
  <!-- flex 布局 -->
  <section>
    <style>
      .flexbox {
        display: flex;
      }
      .left-flex {
        width: 300px;
        background: green;
      }

      .middle-flex {
        flex: 1;
        background: red;
      }

      .right-flex {
        width: 300px;
        background: yellow;
      }
    </style>
    <article class="left-middle-right flexbox" style="margin-top: 140px">
      <div class="left-flex"></div>
      <div class="middle-flex">
        1.flex 布局
      </div>
      <div class="right-flex"></div>
    </article>
  </section>
  <!-- 表格布局 -->
  <section>
    <style>
      .table {
        display: table;
        width: 100%;
      }
      .left-table {
        display: table-cell;
        width: 300px;
        background: green;
      }

      .middle-table {
        display: table-cell;
        background: red;
      }

      .right-table {
        display: table-cell;
        width: 300px;
        background: yellow;
      }
    </style>
    <article class="left-middle-right table">
      <div class="left-table"></div>
      <div class="middle-table">
        表格布局
      </div>
      <div class="right-table"></div>
    </article>
  </section>
  <!-- 网格布局 -->
  <section>
    <style>
      .grid {
        display: grid;
        width: 100%;
        grid-template-rows: 100px;
        grid-template-columns: 300px auto 300px;
      }
      .left-grid {
        background: green;
      }

      .middle-grid {
        background: red;
      }

      .right-grid {
        background: yellow;
      }
    </style>
    <article class="left-middle-right grid">
      <div class="left-grid"></div>
      <div class="middle-grid">
        网格布局
      </div>
      <div class="right-grid"></div>
    </article>
  </section>
</body>
</html>